package com.qjl.shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qjl.shopping.bean.OrderItem;
import com.qjl.shopping.bean.Orders;
import com.qjl.shopping.dao.OrderItemMapper;
import com.qjl.shopping.service.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author liguanghui
 * @Date 2023/5/3
 */
@Service
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem> implements OrderItemService {
    @Autowired
    private OrderItemMapper orderItemMapper;
    @Override
    public Page<OrderItem> selectPage(int pageNum, int pageSize,int orderId, int itemId) {
        Page<OrderItem> page = new Page<>(pageNum,pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("oi_id");
        if(orderId!=0){
            queryWrapper.eq("oi_order_id",orderId);
        }
        if(itemId!=0){
            queryWrapper.eq("oi_item_id",itemId);
        }
        Page<OrderItem> orderItemPage = orderItemMapper.selectPage(page,queryWrapper);
        return orderItemPage;
    }
}
